package miracle.joker.design.interpreter;

public class InterpreterDemo {
    public static void main(String[] args) {
        // 创建表达式和上下文
        Context context = new Context();
        Expression expression = new SubtractExpression(
                new AddExpression(
                        new NumberExpression(10),
                        new NumberExpression(5)
                ),
                new NumberExpression(3)
        );

        // 设置变量值
        context.setVariable("x", new NumberExpression(4));

        // 解释并输出结果
        int result = expression.interpret();
        System.out.println("Result: " + result); // 输出：Result: 12

        System.out.println(context.getVariable("x"));
    }
}
